package com.tzy.springboot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tzy.springboot.entity.SystemLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface SystemLogMapper extends BaseMapper<SystemLog> {

    // 统计各级别日志数量
    @Select("SELECT level, COUNT(*) as count FROM system_log GROUP BY level")
    List<Map<String, Object>> countByLevel();

    // 统计各模块日志数量
    @Select("SELECT module, COUNT(*) as count FROM system_log GROUP BY module ORDER BY count DESC LIMIT 10")
    List<Map<String, Object>> countByModule();
}

